<template>
	<view class="container">
		<!-- <view class="ipt">
			<view><text>押金退还</text></view>
			<text>{{ yajin_price }}元</text>
		</view> -->

		<view class="tit"><!-- 可提现金额：<text>{{userInfo.money}}</text>元 --></view>

		<view class="list">
			<view class="list_item">
				<view class="item_l">
					<!-- #ifdef MP-WEIXIN -->
					<image src="/static/img/detail/weixin-select.png" mode="widthFix"></image>
					<text>押金退还到微信余额</text>
					<!-- #endif -->
					<!-- #ifdef MP-ALIPAY -->
					<image src="/static/img/detail/apily-select.png" mode="widthFix"></image>
					<text>押金退还到支付宝余额</text>
					<!-- #endif -->
				</view>
				<label class="radio"><radio value="1" color="#42b8ff" checked="true" /></label>
			</view>
		</view>

		<button type="default" @click="drawal">确认</button>
	</view>
</template>

<script>
import { cash, isdeposit, capital } from '../../../api/api.js';

export default {
	data() {
		return {
			userInfo: {},
			yajin_price: '',
			is_deposit: 0
		};
	},
	onLoad() {
		this.getOrder();
	},
	onShow() {
		this.userInfo = uni.getStorageSync('user');
		this.yajin_price = uni.getStorageSync('config').yajin_price;
		// console.log(uni.getStorageSync('user'));
	},
	methods: {
		getOrder() {
			isdeposit().then(res => {
				this.is_deposit = res.data.is_deposit;
			});
		},
		drawal() {
			isdeposit().then(res => {
				let is_deposit = res.data.is_deposit;
				// 如果支付了押金，进入押金退回页面
				if (is_deposit == 1) {
					cash({}).then(res => {
						console.log(res);
						uni.showToast({
							icon: 'none',
							title: res.msg
						});
						setTimeout(() => {
							uni.navigateBack()
						}, 1000)
					});
				}
				// 如果没有支付押金，进入押金支付页面
				else if (is_deposit == 0) {
					uni.navigateTo({
						url: '/pages/deposit/deposit'
					});
				}
			});

			// cash({

			// }).then(res => {
			// 	console.log(res)
			// 	if (res.code == 1) {
			// 		uni.showToast({
			// 			icon: 'none',
			// 			title: '申请成功，等后台人员转账'
			// 		})
			// 	}
			// })
			// uni.navigateTo({
			// 	url: '/pages/common/success?id=' + 1
			// })
		}
	}
};
</script>

<style scoped lang="scss">
.container {
	width: 100%;
	height: calc(100% - 30upx);
	background-color: #f6f6f6;
	padding-top: 30upx;
}

.ipt {
	width: 100%;
	height: 90upx;
	background-color: #ffffff;
	display: flex;
	align-items: center;

	text {
		margin-left: 30upx;
	}

	view {
		min-width: 120upx;
		margin-left: 30upx;
		line-height: 90upx;

		text {
			margin: 0;
		}
	}

	// input {
	// 	height: 100%;
	// 	width: calc(100% - 180upx);
	// }
}

.tit {
	height: 30upx;
	line-height: 30upx;
	margin-left: 30upx;
}

.list {
	width: 100%;
	background-color: #ffffff;

	.list_item {
		width: calc(100% - 60upx);
		height: 100upx;
		margin: 0 auto;
		display: flex;
		align-items: center;
		justify-content: space-between;
		border-bottom: 1upx solid #ececee;

		.item_l {
			min-width: 100upx;
			display: flex;
			justify-content: space-between;
			align-items: center;
			font-size: 32upx;

			image {
				width: 40upx;
				margin-right: 15upx;
			}
		}

		.radio {
			transform: scale(0.8);
		}
	}
}

button {
	width: 90%;
	height: 90upx;
	background-color: #3eb8ff;
	border-radius: 45upx;
	margin: 60upx auto;
	line-height: 90upx;
	color: #ffffff;
}
</style>
